|
|
|
|
|
|
|
For simplicity's sake, I have omitted the API declarations from Listing 23.4. I could go on for pages explaining exactly what is happening during each step of TransparentPaint, but I won't because this sub contains the same comments I've made in this listing. Also, following this listing would be more difficult if it were broken into several smaller blocks. After you read the comments for this sub, I encourage you to single-step through the TRANSPARENT.VBP project, which you can get from Macmillan's Web site at www.mcp.com/info. Reading this project will help you to visualize what is happening at each step. |
|
|
|
|
|
|
|
|
Although TransparentPaint is a difficult procedure to follow, using it is easy. Listing 23.5 loads a bitmap from a resource and paints it on the upper-left corner of the form using TransparentPaint. Next, it paints the picture using PaintPicture. The last parameter, vbGreen, tells TransparentPaint to replace any bits in the bitmap that are green, with the background color of the form. The result is shown in Figure 23.5. |
|
|
|
|
|
|
|
|
Listing 23.5 (TRANSPAR.ZIPUsing the TransparentPaint Procedure |
|
|
|
|
|
|
|
|
'*********************************************************************
' Transparent.frm - Demonstrates how to use basTransparent's
' TransparentPaint using a bitmap from a resource file.
'*********************************************************************
Option Explicit
'*********************************************************************
' Gets a StdPicture handle by loading a bitmap from a resource file
' and paints it transparently on the form by using Gray as the mask
' color.
'*********************************************************************
Private Sub cmdPaintTransBmp_Click()
TransparentPaint Me, LoadResPicture(103, 0), 0, 0, QBColor(7)
End Sub |
|
|
|
|
|
|
|
|
Figure 23.5 TransparentPaint is a must
for your multimedia applications. |
|
|
|
|
|
|
|
|
Try replacing the resource file in this project with your own resource file to see how TransparentPaint works. Also, try using different mask colors as well as the images from picture boxes. Now you never have to write an application that appears to be of inferior quality because it doesn't use transparent bitmaps. |
|
|
|
|
|